package com.wowangz.cms.dailyoperation.storechargemanage.service;

import java.util.HashMap;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.wowangz.cms.dailyoperation.storechargemanage.pojo.StoreChargeManage;
import com.wowangz.cms.syscore.exception.ServiceException;
import com.wowangz.cms.syscore.service.BaseService;

public class StoreChargeManageService extends BaseService {

	private Logger logger = LoggerFactory.getLogger(StoreChargeManageService.class);
	
	/**
	 * 分页查询总条数
	 * 
	 * @param map
	 * @return
	 */
	public long findResultCount(HashMap<String, Object> map) throws ServiceException {
		Long countNum = this.getSqlSession().selectOne("StoreChargeManage.queryStoreChargeManageCount", map);
		return countNum;
	}

	/**
	 * 查询记录集合
	 * 
	 * @param map
	 * @return
	 */
	public List<StoreChargeManage> findResultList(HashMap<String, Object> map) throws ServiceException {
		List<StoreChargeManage> list = this.getSqlSession().selectList("StoreChargeManage.queryStoreChargeManagePage", map);
		return list;
	}
	
	/**
	 * 新增商户收费
	 * @param charge
	 * @throws ServiceException
	 */
	public void insertchargemanage(StoreChargeManage storeChargeManage) throws ServiceException{
		this.getSqlSession().insert("StoreChargeManage.insertStoreChargeManage",storeChargeManage);
	}
	
	/**
	 * 新增商户收费
	 * @param charge
	 * @throws ServiceException
	 */
	public void insertchargemanageTemp(StoreChargeManage storeChargeManage) throws ServiceException{
		this.getSqlSession().insert("StoreChargeManage.insertStoreChargeManageTemp",storeChargeManage);
	}
	
	public boolean validationStoreChargeManage(StoreChargeManage storeChargeManage) throws ServiceException{
		List<StoreChargeManage> list = this.getSqlSession().selectList("StoreChargeManage.validationStoreChargeManage",storeChargeManage);
		if(list.size()>0){
			return true;
		}else{
			return false;
		}
	}
	
	/**
	 *  修改商户收费管理表
	 * @param charge
	 * @throws ServiceException
	 */
	public void updateStoreChargeManageByMap(HashMap<String,Object> hashMap) throws ServiceException {
		this.getSqlSession().update("StoreChargeManage.updateStoreChargeManageByMap", hashMap);
	}
	
	/**
	 * 修改商户收费管理临时表
	 * @param hashMap
	 * @throws ServiceException
	 */
	public void updateStoreChargeManageTempByMap(HashMap<String,Object> hashMap) throws ServiceException{
		this.getSqlSession().update("StoreChargeManage.updateStoreChargeManageTempByMap", hashMap);
	}
	
	
	/**
	 * 通过ID查询商户收费数据
	 * @param hashMap
	 * @return
	 * @throws ServiceException
	 */
	public StoreChargeManage queryStoreChargeManageByID(HashMap<String,Object> hashMap) throws ServiceException{
		StoreChargeManage storeChargeManage = (StoreChargeManage)this.getSqlSession().selectOne("StoreChargeManage.queryStoreChargeManageByID",hashMap);
		return storeChargeManage;
	}
	
	/**
	 * 通过ID查询商户收费数据
	 * @param hashMap
	 * @return
	 * @throws ServiceException
	 */
	public StoreChargeManage queryStoreChargeManageTempByID(HashMap<String,Object> hashMap) throws ServiceException{
		StoreChargeManage storeChargeManage = (StoreChargeManage)this.getSqlSession().selectOne("StoreChargeManage.queryStoreChargeManageTempByID",hashMap);
		return storeChargeManage;
	}
	
	/**
	 * 删除商户收费主表
	 * @param id
	 * @throws ServiceException
	 */
	public void deleteStoreChargeManageByID(Long id) throws ServiceException{
		this.getSqlSession().delete("StoreChargeManage.deleteStoreChargeManageByID",id);
	}
	
	
	/**
	 * 删除商户收费临时表
	 * @param id
	 * @throws ServiceException
	 */
	public void deleteStoreChargeManageTempByID(Long id) throws ServiceException{
		this.getSqlSession().delete("StoreChargeManage.deleteStoreChargeManageTempByID",id);
	}
}
